package jslog

import (
	"gitee.com/zhongguo168a/gocodes/myx/logx/iface"
	"github.com/gopherjs/gopherjs/js"
	"honnef.co/go/js/console"
)

type Logger struct {
	Name string
}

func (l *Logger) Ok(a ...interface{}) {
	a = append([]interface{}{`[ok   ]`}, a...)
	console.Log(a...)
}

func (l *Logger) Fail(a ...interface{}) {
	a = append([]interface{}{`[fail ]`}, a...)
	console.Log(a...)
}

func (l *Logger) Msg(a ...interface{}) {
	console.Log(a...)
}

func (l *Logger) Debug(a ...interface{}) {
	a = append([]interface{}{`[debug]`}, a...)
	c := js.Global.Get("console")
	c.Call("debug", a...)
}

func (l *Logger) Warn(a ...interface{}) {
	a = append([]interface{}{`[warn ]`}, a...)
	console.Warn(a...)
}
func (l *Logger) Info(a ...interface{}) {
	a = append([]interface{}{`[info ]`}, a...)
	console.Log(a...)
}

func (l *Logger) Error(a ...interface{}) {
	a = append([]interface{}{`[error]`}, a...)
	console.Error(a...)
}

func (l *Logger) Fatal(a ...interface{}) {
	a = append([]interface{}{`[fatal]`}, a...)
	console.Error(a...)
}

func (l *Logger) With(m map[string]interface{}) iface.ILogger {
	return l
}
